package com.jwater.core.net;
/**
 * @description:
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public interface NodeHandler {
	/**
	 * 建立连接通知
	 */
	public void onConnect(Node node);

	/**
	 * 断开连接通知
	 */
	public void onDisconnect(Node node);

	/**
	 * 接受到数据回调
	 * 
	 * @param data
	 */
	public void onData(Node node, String dataType, byte[] data);

	/**
	 * 同步方法回调
	 * 
	 * @param method
	 * @param args
	 * @return
	 */
	public byte[] onSyncCall(Node node, String method, byte[] args);

	/**
	 * 异步方法回调
	 * 
	 * @param method
	 * @param args
	 * @param callback
	 */
	public void onAsyncCall(Node node, String method, byte[] args, ReturnCallback callback);

	public interface Callback {
		public void onResult(Node node, byte[] result, Exception exception);
	}

	public interface ReturnCallback {
		public void doReturn(byte[] result, Exception exception);
	}
}
